|
|
|
|
|
|
|
certainly feasible, it's overkill for this situation. The ServiceStatus class will correspond to the ENUM_SERVICE_STATUS structure and also handle the SERVICE_STATUS structure. |
|
|
|
|
|
|
|
|
Now it's a relatively simple matter to decide how to allocate methods to the classes. |
|
|
|
|
|
|
|
|
The ServiceManager class will include the following methods and properties: |
|
|
|
|
|
|
|
|
OpenSCManager function. Used to initialize the ServiceManager function. Unfortunately, VB doesn't support parameterized constructors2 (as is possible with C++), so you just have to remember to call this method after creating the class. |
|
|
|
|
|
|
|
|
EnumServicesStatus. Used to enumerate services, this function returns a collection containing a ServiceStatus object for each service. |
|
|
|
|
|
|
|
|
OpenService. Used to open a service, this function returns a ServiceObject object. |
|
|
|
|
|
|
|
|
The ServiceObject class will include the following methods and properties: |
|
|
|
|
|
|
|
|
Initialize. A Friend method used by the ServiceManager class to initialize a newly created object. |
|
|
|
|
|
|
|
|
ServiceName. A read-only property used to get the name of the service. |
|
|
|
|
|
|
|
|
QueryServiceStatus. A function that returns a ServiceStatus object that defines the current state of the service. |
|
|
|
|
|
|
|
|
ServiceControl. A function that corresponds to the ServiceControl API function. |
|
|
|
|
|
|
|
|
StartService. A function that corresponds to the StartService API function. |
|
|
|
 |
|
 |
|
|
2 When a Visual Basic class is created, its Initialize event is called. This event is called a "constructor" in C++ objectsthough the mechanism by which they are called is very different. In C++, it is possible for the function creating an object to pass parameters to the object's constructor. In fact, an object can have more than one constructor function, each with a different set of parameters. |
|
|
|
|
|